﻿namespace EyeOpen.Data
{
    using System.Collections.Generic;

    public abstract class BaseDataContext<T> : BaseDataContext where T : IDataContext
    {
        private readonly T dataContext;

        protected BaseDataContext(T dataContext)
        {
            this.dataContext = dataContext;
        }

        protected T DataContext
        {
            get
            {
                return dataContext;
            }
        }

        public override IEnumerable<TResult> GetByQuery<TSource, TResult>(Queries.IQuery<TSource, TResult> query)
        {
            return DataContext.GetByQuery(query);
        }

        public override void BeginTransaction()
        {
            DataContext.BeginTransaction();
        }

        public override void Commit()
        {
            DataContext.Commit();
        }

        public override void Rollback()
        {
            DataContext.Rollback();
        }

        public override void SaveChanges()
        {
            DataContext.SaveChanges();
        }

        public override void Dispose()
        {
            DataContext.Dispose();
        }
    }
}